package com.ztjy.repository.biz.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ztjy.bean.RkWarehouse;
import com.ztjy.repository.biz.RkWarehouseBiz;
import com.ztjy.repository.dao.RkWarehouseDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RkWarehouseBizImpl implements RkWarehouseBiz {
    @Autowired
    private RkWarehouseDao rkdao;

    @Override
    public PageInfo<RkWarehouse> findAllRkWare(RkWarehouse rkWarehouse, Integer pageNo, Integer pageSize) {
        PageHelper.startPage(pageNo,pageSize);
        List<RkWarehouse> allRkWarehouse = rkdao.findAllRkWarehouse(rkWarehouse);
        PageInfo<RkWarehouse> pageInfo=new PageInfo<RkWarehouse>(allRkWarehouse);
        return pageInfo;
    }

    @Override
    public List<RkWarehouse> findAllRkWarehouse(RkWarehouse rkWarehouse) {
        return rkdao.findAllRkWarehouse(rkWarehouse);
    }

    @Override
    public RkWarehouse findRkWarehouseById(Integer id) {
        return rkdao.findRkWarehouseById(id);
    }


    @Override
    public List<RkWarehouse> findRkWarehouseByIdList(String rkIndent) {
        RkWarehouse rkWarehouse=new RkWarehouse();
        rkWarehouse.setRkIndent(rkIndent);
        return rkdao.findAllRkWarehouse(rkWarehouse);
    }

    @Override
    public boolean AddRkWarehouse(RkWarehouse warehouse) {
        boolean flag = false;
        try {
            int row = rkdao.AddRkWarehouse(warehouse);
            flag = (row != 0) ? true : false;
        } catch (Exception ex) {
            ex.printStackTrace();
            flag = false;
        }
        return flag;
    }

    @Override
    public boolean UpdateRkWarehouse(RkWarehouse warehouse) {
        boolean flag = false;
        try {
            int row = rkdao.UpdateRkWarehouse(warehouse);
            flag = (row != 0) ? true : false;
        } catch (Exception ex) {
            ex.printStackTrace();
            flag = false;
        }
        return flag;

    }
}
